package com.sdna.unified;

import java.io.UnsupportedEncodingException;

import com.sdna.rpc.RPCClientMgr;
import com.sdna.rpc.RPCClient;
import com.sdna.rpc.ParameterBuilder;
import java.util.HashMap;


/**
 * @author gaoyong01
 * 系统消息服务
 * 
 * 主要是包括2大块服务
 * 1：表MESSAGE_NOTIFICATION (系统通知表) notify的操作
 * 2：表MESSAGE_REQUEST (请求表,主要为邀请游戏或者安装应用) requestmessage的操作
 * 3：会调用到 CommonMessageService 的一些公共操作
 */

/**
  * This file is generated by GenerateServiceClient.py, SVN location:
  *     svn://192.168.90.69/i.sdo.com/sdk/trunk/unified/GenerateServiceClient.py
  *
  * Please DO NOT change this file!!! it is just a wrapper of unified service api.   
  */

public class SystemMessageServiceClient {

	/*
	 * 得到系统消息(分页版)
	 */
	static public String getSystemNotify(Long sdid, HashMap<String, Object> parameters) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		if (parameters.containsKey("startIndex")) pb.add("startIndex", (Integer)parameters.get("startIndex"));
		if (parameters.containsKey("count")) pb.add("count", (Integer)parameters.get("count"));
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.getSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 得到单条系统消息
	 */
	static public String getASystemNotify(Long id, Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("id", id);
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.getASystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 添加系统消息
	 */
	static public String addSystemNotify(Long senderid, Long receiverid, String content, Integer type) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("senderid", senderid);
		pb.add("receiverid", receiverid);
		pb.add("content", content);
		pb.add("type", type);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.addSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 更新系统消息 主要目的(改变已读状态)
	 */
	static public String updateSystemNotify(Long id, Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("id", id);
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.updateSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	static public String updateAllSystemNotify(Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.updateAllSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 删除系统消息
	 */
	static public String deleteSystemNotify(Long sdid, Long id) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		pb.add("id", id);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.deleteSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 删除所有系统消息
	 */
	static public String deleteAllSystemNotify(Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.deleteAllSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 删除所有系统消息
	 */
	static public String deleteAllReadedSystemNotify(Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.deleteAllReadedSystemNotify", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 得到用户请求(分页版)
	 */
	static public String getPersonalRequest(Long sdid, HashMap<String, Object> parameters) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		if (parameters.containsKey("startIndex")) pb.add("startIndex", (Integer)parameters.get("startIndex"));
		if (parameters.containsKey("count")) pb.add("count", (Integer)parameters.get("count"));
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.getPersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 得到用户请求(分页版)
	 */
	static public String getAPersonalRequest(Long id, Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("id", id);
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.getAPersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 添加用户请求
	 */
	static public String addPersonalRequest(Long senderid, Long receiverid, String content, Integer type) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("senderid", senderid);
		pb.add("receiverid", receiverid);
		pb.add("content", content);
		pb.add("type", type);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.addPersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 更新用户请求 主要目的(改变已读状态)
	 */
	static public String updatePersonalRequest(Long id, Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("id", id);
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.updatePersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	static public String updateAllPersonalRequest(Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.updateAllPersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 删除用户请求
	 */
	static public String deletePersonalRequest(Long sdid, Long id) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		pb.add("id", id);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.deletePersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}

	/*
	 * 删除用户请求
	 */
	static public String deleteAllPersonalRequest(Long sdid) throws UnsupportedEncodingException{
		ParameterBuilder pb = new ParameterBuilder();
		pb.add("sdid", sdid);
		RPCClient client = RPCClientMgr.getClient();
		try {
			return client.doRequest("SystemMessageService.deleteAllPersonalRequest", pb.toString());
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			RPCClientMgr.restore(client);
		}
	}
}